package com.lkxicy.wos.controller;


import com.lkxicy.wos.service.SalaryPaymentService;
import com.lkxicy.wos.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lkxicy
 * @since 2020-11-30
 */
@RestController
@RequestMapping("/wos/v1/salaryPayment")
public class SalaryPaymentController {

    @Autowired
    private SalaryPaymentService salaryPaymentService;

    /**
     * 查询某个员工的全部薪资记录
     * @return
     */
    @GetMapping("searchOneAllSalaryRecord")
    public Response searchOneAllSalaryRecord(@RequestParam("staffNumber") String staffNumber){
        return Response.success(salaryPaymentService.searchAllSalaryRecord(staffNumber));
    }

    /**
     * 单个员工发工资(增加单个员工工资记录)
     * @return
     */
    @PostMapping("payOneSalary")
    public Response payOneSalary(@RequestParam("staffNumber") String staffNumber,
                              @RequestParam("effectTime") Date effectTime){
        return Response.success(salaryPaymentService.addSalaryRecord(staffNumber,effectTime));
    }

    /**
     * 给全体员工发工资(增加全体员工工资记录)
     * @param effectTime
     * @return
     */
    @PostMapping("paySalary")
    public Response paySalary(@RequestParam("effectTime") Date effectTime){
        return Response.success(salaryPaymentService.addAllSalaryRecord(effectTime));
    }





}

